package com.hzxy.yiyid.web.tool;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class FileUtil {

	public static void main(String[] args) throws IOException {
		String inputFileName = "D:/定点医疗机构.csv";
		String outputFileName = "D:/定点医疗机构-SQL.sql";
		BufferedReader br = new BufferedReader(new FileReader(inputFileName));
		BufferedWriter bw = new BufferedWriter(new FileWriter(outputFileName));
		String readLine = null;
		while((readLine = br.readLine())!= null ) {
			bw.write(generateYILIAOSQL(readLine));
		}
		bw.flush();
	}
	/**
	 * 生成定点医药机构插入SQL
	 * @param line
	 * @return
	 */
	public static String generateYIYAOSQL(String line) {
		String[] yyArray = line.split(",");
		StringBuilder yySB = new StringBuilder();
		yySB.append("INSERT INTO assign_organization(`id`, `ffrq`, `lxdh`, `dz`, `ddlb`, `jgmc`,`city`,`city_code`,`type`,`save_time`,`update_time`) VALUES(");
		yySB.append(yyArray[0]);
		yySB.append(",'");
		yySB.append(yyArray[1]);
		yySB.append("','");
		yySB.append(yyArray[2]);
		yySB.append("','");
		yySB.append(yyArray[3]);
		yySB.append("','");
		yySB.append(yyArray[4]);
		yySB.append("','");
		yySB.append(yyArray[5]);
		yySB.append("','杭州市' ,  '330100'");
		yySB.append("," + 0 + ",");
		yySB.append("'2023-06-02 12:23:34','2023-06-10 12:23:34');" );
		yySB.append("\n");
		return yySB.toString();
	}
	/**
	 * 生成定点医疗机构插入SQL
	 * @param line
	 * @return
	 */
	public static String generateYILIAOSQL(String line) {
		String[] ylArray = line.split(",");
		StringBuilder ylSB = new StringBuilder();
		ylSB.append("INSERT INTO assign_organization(`id`, `ffrq`, `lxdh`, `jgmc`, `dz`, `dj`, `ddlb`,`jgbm`, `city`,`city_code`,`type`,`save_time`,`update_time`) VALUES(");
		ylSB.append(ylArray[0]);
		ylSB.append(",'");
		ylSB.append(ylArray[1]);
		ylSB.append("','");
		ylSB.append(ylArray[2]);
		ylSB.append("','");
		ylSB.append(ylArray[3]);
		ylSB.append("','");
		ylSB.append(ylArray[4]);
		ylSB.append("','");
		ylSB.append(ylArray[5]);
		ylSB.append("','");
		ylSB.append(ylArray[6]);
		ylSB.append("','");
		ylSB.append(ylArray[7]);
		ylSB.append("','杭州市' ,  '330100'");
		ylSB.append("," + 1 + ",");
		ylSB.append("'2023-06-02 12:23:34','2023-06-10 12:23:34');" );
		ylSB.append("\n");
		return ylSB.toString();
	}
}
